{% extends 'index.html' %}

{% block panel %}
<li class="active"><a href="/main/">Inicio</a></li>
<li class="dropdown">
	<a href="#" class="dropdown-toggle" data-toggle="dropdown">Regístrate<b class="caret"></b>
	</a>
	<ul class="dropdown-menu">
	<li><a href="/nuevovoluntario/" >Voluntario</a></li>
	<li><a href="/nuevaorg/" >Organización</a></li>
	<li><a href="/nuevaempresa/" >Empresa Privada</a></li>
	</ul>
</li>
<li><a href="/contact/">Contacto</a></li>
<li><a href="/about/">Acerca de</a></li>

{% endblock %}

{% block signin %}
<form name="log" class="navbar-form pull-right" action = "." method="POST" onsubmit="return validation();">{% csrf_token %}
	<input class="span2" type="text" class="input-small" placeholder="Usuario" name="username">
	<input class="span2" type="password" class="input-small" placeholder="Contraseña" name = "password">
	<button type="submit" class="btn" value="login" name="login" >Iniciar sesión</button>
</form>

{% if invalid %}
	<div class="alert alert-error span4">
		<button type="button" class="close" data-dismiss="alert">x</button>
		<p>Usuario y/o contraseña incorrectos</p>
	</div>
{% else %}
<div id="alertas"></div>
{% endif %}
{% endblock %}

{% block scripts %}
<script>
	function validation(){
		document.log.username.value = document.log.username.value.toLowerCase();
		var user = document.log.username.value,
		pass = document.log.password.value;
		if (user==null || user=='' || pass==null || pass==''){
			if ($('#alerta1').length==0){
				$('#alertas').append('<div id="alerta1" class="alert alert-error span4"><button type="button" class="close" data-dismiss="alert">x</button><p>Por favor agregue un usuario/contraseña</p></div>');
			}
			return false;
		}
		return true;
	}
	
	
	
</script>
{% endblock %}
